#include "StdAfx.h"
#include "ObjectName.h"
#include "Utility.h"

using namespace Pattern;

Pattern::ObjectName::ObjectName(const std::string& name)
{	
	text = name;
}

Pattern::ObjectName::ObjectName()
{
}

Pattern::ObjectName::ObjectName( const ObjectName& ref )
{
	text = ref.text;
	hash = ref.hash;
}

Pattern::ObjectName::ObjectName( const char* name )
{
	text = name;
}

Pattern::ObjectName::~ObjectName(void)
{
}

Pattern::ObjectName::operator const std::string()
{
	return text;
}

Pattern::ObjectName::operator const Uint()
{
	return hash;
}

bool Pattern::ObjectName::operator ==(const ObjectName& another) const
{
	return hash == another.hash;
}

bool Pattern::ObjectName::operator !=(const ObjectName& another) const
{
	return hash != another.hash;
}

bool Pattern::ObjectName::IsEmpty() const
{
	return text.empty();
}

void Pattern::ObjectName::Text(const std::string& name)
{
	text = name;
	hash = Utility::HashString(name);
}

const std::string Pattern::ObjectName::Text() const
{
	return text;
}

Uint Pattern::ObjectName::GetHash() const
{
	return hash;
}

void Pattern::ObjectName::Clear()
{
	text.clear();
	hash = Utility::HashString(text);
}